/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including but not limited to the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to provide persons with access to the Software
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGE OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

<template>
  <div class='home-header'>
    <MultiDiversionVue :direction='multiDiversionDirection'>
      <DiversionItemVue name='firstTitle' 
                        :diversionCols='tabBarCols' 
                        :diversionGap='barGap'>
        <div class='top-tab-bar'>
          <span class='top-tab-bar-text-selected'>华为</span>
          <span class='top-tab-bar-text'>AITO汽车</span>
          <span class='top-tab-bar-text'>华为智选</span>
          <span class='top-tab-bar-text'>生态周边</span>
        </div>
      </DiversionItemVue>
      <DiversionItemVue name='secondTitle' 
                        :diversionCols='searchBarCols' 
                        :diversionGap='barGap'>
        <div class='search-bar'>
          <input type='search-bar-text' 
                 class='search-bar-input' 
                 placeholder='搜索...' />
          <img class='search-bar-image' 
               src='../../assets/line_viewfinder.svg' />
          <img class='search-bar-image' 
               src='../../assets/msg_big.png' />
        </div>
      </DiversionItemVue>
    </MultiDiversionVue>
  </div>
</template>
<script setup>
import { onUnmounted, ref } from 'vue';
import { MultiDiversionVue, DiversionItemVue } from 'web-multidevice-advanced-vue3/src';
import { breakpointManager } from '../../utils/breakpointInit';

const multiDiversionDirection = ref('vertical');
const tabBarCols = ref('7');
const searchBarCols = ref('5');
const barGap = ref('10px');

const unsubscribe = breakpointManager.subscribeToBreakpoint(() => {
  multiDiversionDirection.value = breakpointManager.useBreakpointValue({
    xs: 'vertical',
    sm: 'vertical',
    md: 'horizontal',
    lg: 'horizontal',
    xl: 'horizontal',
  });

  tabBarCols.value = breakpointManager.useBreakpointValue({
    xs: '12',
    sm: '12',
    md: '7',
    lg: '8',
    xl: '8',
  });

  searchBarCols.value = breakpointManager.useBreakpointValue({
    xs: '12',
    sm: '12',
    md: '5',
    lg: '4',
    xl: '8',
  });
});

onUnmounted(() => {
  unsubscribe();
});

</script>
<style lang='less' scoped>
@import './index.less';
</style>